// pages/lib/addLib/addLib.js
var app = getApp()
var hander = require('../../../utils/dataHander.js')
var call = require("../../../utils/request.js")
Page({
  /**
   * 页面的初始数据
   */
  data: {
    modalHidden: true,
    contactWay: '',
    leaveMsg: '',
    modalMsg: '',
    modaltap: 0, 
  },
  getContent: function (e) {
    var str = e.detail.value;
    this.setData({
      leaveMsg: str.replace(/(^\s*)|(\s*$)/g, "")
    })
  },
  getTel: function (e) {
    var str = e.detail.value;
    this.setData({
      contactWay: str.replace(/(^\s*)|(\s*$)/g, "")
    })
  },
  shuffleSuc: function (data) {
    console.log(data);
  },
  fail: function () {
    console.log("失败")
  },
  //添加留言
  modalTap0: function (e) {
    var that = this;
    if (that.data.leaveMsg.length == 0) {
      wx.showToast({
        title: '内容不能为空',
      })
      return;
    }
    call.request('/leave-msg/create',that.data,this.shuffleSuc, this.fail);
    wx.navigateBack({//返回
      delta: 1
    })
    wx.showToast({
      title: "反馈成功",
      duration: 2000
    })
  },
  //取消
  modalCancel: function (e) {
    this.setData({ modalHidden: true })
  }
})